<%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%>
<%@ page contentType="text/html;charset=UTF-8" %>
<%@page import="com.lmpop.trade.ti_channel.*" %>
<%@page import="com.lmpop.trade.ti_news.*" %>
<%@page import="java.util.*" %>
<%@page import="com.lmpop.frame.util.PageTools" %>
<%
	request.setCharacterEncoding("UTF-8");
 
	Ti_channel ti_channel=new Ti_channel();
    Ti_channelInfo ti_channelInfo = new Ti_channelInfo();

	String ch_namex = "";
	if(request.getParameter("ch_namex")!=null && !request.getParameter("ch_namex").equals("")){
		ch_namex = request.getParameter("ch_namex");
		ti_channel.setCh_name(ch_namex);
	   }
    String break_ch_id="";
	String ch_idx = "";
	if (request.getParameter("up_ch_id") != null&& !request.getParameter("up_ch_id").equals("")) {
		ch_idx = request.getParameter("up_ch_id");
		if(!ch_idx.equals("000000000000000")){
		break_ch_id=ti_channelInfo.getUp_ch_id(ch_idx);
		 }                                 
		}
	   else{
		ch_idx="000000000000000";
		  }	
		 ti_channel.setUp_ch_id(ch_idx);
		String iStart = "0";
		int limit = 20;
		if(request.getParameter("iStart")!=null) iStart = request.getParameter("iStart");
		List list = ti_channelInfo.getListByPage(ti_channel,Integer.parseInt(iStart),limit);
		
		int counter = 0;
		counter =ti_channelInfo.getCountByObj(ti_channel);
		String pageString ="";
		pageString = new PageTools().getGoogleToolsBar(counter,"index.jsp?up_ch_id=" + ch_idx +"&ch_namex="+ch_namex+"&iStart=",Integer.parseInt(iStart),limit);
		
		String para ="up_ch_id=" + ch_idx +"&ch_namex="+ch_namex+"&iStart="+Integer.parseInt(iStart);
		
%>
<html>
  <head>
    
    <title>栏目管理</title>
		<link href="/program/admin/index/css/style.css" rel="stylesheet" type="text/css">
	  <script type="text/javascript" src="channel.js"></script>
</head>

<body>
	<table width="100%" cellpadding="0" cellspacing="0" border="0">
		<tr>
			<td width="90%">
				<h1>栏目管理</h1>
			</td>
			<td>
				<a href="addInfo.jsp"><img src="/program/admin/index/images/post.gif" /></a>
			</td>
		</tr>
	</table>
	
	<form action="index.jsp" name="indexForm" method="post">
	
	<table width="100%" cellpadding="0" cellspacing="0" style="border:1px"  class="dl_su">
		<tr>
			<td align="left">
				栏目名称:<input name="ch_namex" id="ch_namex"type="text" onBlur="this.value=trim(this.value);" />
				<input name="searchInfo" type="button" value="查询" onclick="searchForm()"/>	
			</td>
		</tr>
	</table>

	<table width="100%" cellpadding="0" cellspacing="0" border="0" class="tablehe">
		<tr><td align="center"><%=pageString %></td></tr>
	</table>
	
	<% 
		int listsize = 0;
		if(list!=null && list.size()>0){
			listsize = list.size();
	%>
	
	<table width="100%" cellpadding="0" cellspacing="0" border="0" class="dl_bg">
		<tr>
			<td  width="90%">
				<input type="button" name="delInfo" onclick="delIndexInfo()" value="删除" class="buttab"/>			
			</td>
			<td >
				总计:<%=counter %>条
			</td>
		</tr>
	</table>
	
	<table width="100%" cellpadding="1" cellspacing="1" class="listtab" border="0">
		<tr>
			<th width="5%" align="center">
				<input type="checkbox" name="checkall" id="checkall" onclick="selectAll()"></th>
			
		  	<th>栏目名称</th>
		  	
		   <th>栏目标识</th>
				
		  	<th>上级分类</th>
		  	
		  	<th>等级</th>
 
 		  	<th>新增子分类</h>

			<th width="10%">修改</th>
	  		<th width="10%">删除</th>
		</tr>
		
		
		<% 
		String ch_id="",ch_name="",up_ch_id="",ch_level="",in_date="",up_ch_name="";
		  		for(int i=0;i<list.size();i++){
		  					Hashtable map = (Hashtable)list.get(i);		  			
		  			  		if(map.get("ch_id")!=null) ch_id = map.get("ch_id").toString();
						  	if(map.get("ch_name")!=null) ch_name = map.get("ch_name").toString();
						  	if(map.get("up_ch_id")!=null) up_ch_id = map.get("up_ch_id").toString();
						  	if(map.get("ch_level")!=null) ch_level = map.get("ch_level").toString();				 
						  	if(map.get("in_date")!=null) in_date = map.get("in_date").toString();
						    if(in_date.length()>19)in_date=in_date.substring(0,19);              
						    int bool=0;
						    
                if(!ch_idx.equals("000000000000000")){
                 		    up_ch_name = ti_channelInfo.getChName(ch_idx);		 
								} else{
								  up_ch_name="无上级";
								}
						Boolean hasDown =  ti_channelInfo.checkSonById(ch_id);
						  %>
		
		<tr>
			<td width="5%" align="center">
				<input type="checkbox" name="checkone<%=i %>" id="checkone<%=i %>" value="<%=ch_id %>" />
				<input type="hidden" name="ckecknews<%=i%>" id="ckecknews<%=i%>" value="<%=0%>">
				<input type="hidden" name="bool<%=i%>" id="bool<%=i%>" value="<%=bool%>">
				</td>
		  	<td>
							
				<%
	  		 if(hasDown){
	  		%>	<input type="hidden" name="hasdown<%=i%>" value="1" id="hasdown<%=i%>" />
	  			<a href="index.jsp?up_ch_id=<%=ch_id%>" title="查看该栏目下级频道">
				<img src="/program/admin/images/1.gif" border="0" style="cursor:pointer;"/>		
				<font color="black"><%=ch_name%></font></a>
			<%
	  		}else{
	  		%>
		  		<font color="black"><%=ch_name%></font></a>
		  	<%}%>
							
           </td>
		  	
			<td><%=ch_id%></td>
			
		  	<td><%=up_ch_name%></td>
		  	
		  	<td><%=ch_level%></td>
		  	<td >							
					<a href="addInfo.jsp?up_ch_id=<%=ch_id%>&up_ch_level=<%=String.valueOf(Integer.parseInt(ch_level)+1)%>" >
							
						<img src="/program/admin/images/add.gif" width="16" height="16" border="0" alt="新增下级频道"></a>		
						</td>
		  	
			<td width="10%"><a href="updateInfo.jsp?ch_id=<%=ch_id %>&<%=para%>">
				<img src="/program/admin/images/edit.gif" border="0" title="修改" /></a></td>
	  		<td width="10%"><a href="javascript:delOneNews('<%=i%>','<%=ch_id%>','<%=i%>');">
	  			<img src="/program/admin/images/delete.gif" border="0" title="删除" /></a></td>
		</tr>
		
		  <%
		  		}
		  %>
		
	</table>
	
	<table width="100%" cellpadding="0" cellspacing="0" border="0" class="dl_bg">
		<tr>
			<td  width="90%">
				<input type="button" name="delInfo" onclick="delIndexInfo()" value="删除" class="buttab"/>
				
			</td>
			<td >
				总计:<%=counter %>条
			</td>
		</tr>
	</table>
	<table width="100%" cellpadding="0" cellspacing="0" border="0" class="tablehe">
		<tr><td align="center"><%=pageString%></td></tr>
	</table>
	<center>
	
	<%
		 }
	%>
	<%if(!ch_idx.equals("000000000000000")){%>
			   <input type="button" class="buttab"name="fanhui" value="返回上级" onClick="location.href='index.jsp?up_ch_id=<%=break_ch_id%>'" style="cursor:pointer;">
			<%}%>
		</center>
	<input type="hidden" name="up_ch_id" id="up_ch_id" value="<%=ch_idx %>" />
	  <input type="hidden" name="listsize" id="listsize" value="<%=listsize %>" />
	  <input type="hidden" name="pkid" id="pkid" value="" />
	  <input type="hidden" name="bpm_id" id="bpm_id" value="3449" />
	  </form>
</body>

</html>
